package com.minelx.parallel;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class MainTest2 {
	public static void main(String[] args) {
		second();
	}

	private static void second() {
		long used = System.currentTimeMillis();
		int asInt = IntStream.rangeClosed(1, 1000000).reduce(Integer::sum).getAsInt();
		System.out.println(System.currentTimeMillis() - used);
		System.out.println("asInt = " + asInt);
	}

	private static void first() {
		List<Integer> integers = IntStream.rangeClosed(1, 1000000).boxed().collect(Collectors.toList());

		Integer sum = 0;
		long used = System.currentTimeMillis();
		for (Integer integer : integers) {
			sum += integer;
		}
		System.out.println("cost: " + (System.currentTimeMillis() - used));
		System.out.println("sum = " + sum);
	}
}
